﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using DevExpress.XtraNavBar;

namespace td.Core
{
    public partial class NavBarButton : NavBarItem,td.Core.IStatusUpdate
    {
        private object caller;
        private AbstractToolButtonCommand Info;


        public NavBarButton(AbstractToolButtonCommand info, object caller)
        {
            this.Info = info;
            this.caller = caller;
            this.LargeImage = info.largeImage;
            this.SmallImage = info.smallImage;
            this.LinkClicked += new NavBarLinkEventHandler(NavBarButton_LinkClicked);
            this.Enabled = info.IsEnabled;
            this.UpdateText();
        }

        void NavBarButton_LinkClicked(object sender, NavBarLinkEventArgs e)
        {
            if (this.Info != null) this.Info.Run();
        }

     
        public virtual void UpdateStatus()
        {
            if (this.Info != null)
            {
                base.Enabled = this.Info.IsEnabled;
            }
        }

        public virtual void UpdateText()
        {
            if (this.Info != null)
            {
                this.Caption = this.Info.Caption;
            }
        }

    }
}
